home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / nihcl-30.lha / nihcl-3.0 / ex / Line.c < prev    next >
C/C++ Source or Header  |  1990-05-15  |  1KB  |  73 lines

  1. // Line.c -- Line shape
  2.  
  3. #include "Line.h"
  4. #include "nihclIO.h"
  5.  
  6. #define THIS Line
  7. #define BASE Shape
  8. #define BASE_CLASSES Shape::desc()
  9. #define MEMBER_CLASSES Point::desc()
  10. #define VIRTUAL_BASE_CLASSES
  11.  
  12. DEFINE_CLASS(Line,1,"$Header: /afs/alw.nih.gov/unix/sun4_40c/usr/local/src/nihcl-3.0/share/ex/RCS/Line.c,v 3.0 90/05/15 22:43:39 kgorlen Rel $",NULL,NULL);
  13.  
  14. void Line::move(const Point& d)
  15. {
  16.     Shape::move(d);     // move the origin
  17.     p += d;
  18. }
  19.  
  20. void Line::draw() const
  21. {
  22.     printOn();
  23.     cout << endl;
  24. }
  25.  
  26. bool Line::operator==(const Line& l) const
  27. {
  28.     if (origin() == l.origin())
  29.         if (p == l.p) return YES;
  30.     return NO;
  31. }
  32.  
  33. const Class* Line::species() const  { return &classDesc; }
  34.  
  35. bool Line::isEqual(const Object& p) const
  36. {
  37.     return p.isSpecies(classDesc) && *this==(const Line&)p;
  38. }
  39.  
  40. unsigned Line::hash() const
  41. {
  42.     return origin().hash() ^ p.hash();
  43. }
  44.  
  45. void Line::deepenShallowCopy()
  46. {
  47.     Shape::deepenShallowCopy();
  48.     p.deepenShallowCopy();
  49. }
  50.  
  51. void Line::printOn(ostream& strm) const
  52. {
  53.     strm << "Line from " <<
  54.       *TransformStack::transform.current() + origin();
  55.     strm << " to " << *TransformStack::transform.current() + p;
  56. }
  57.  
  58. Line::Line(OIOin& strm) : Shape(strm),p(strm) {}
  59.  
  60. void Line::storer(OIOout& strm) const
  61. {
  62.     Shape::storer(strm);
  63.     p.storeMemberOn(strm);
  64. }
  65.  
  66. Line::Line(OIOifd& fd) : Shape(fd),p(fd) {}
  67.  
  68. void Line::storer(OIOofd& fd) const
  69. {
  70.     Shape::storer(fd);
  71.     p.storeOn(fd);
  72. }
  73.